package com.xcity.game.combat.skill.impl;

import java.util.List;

import com.xcity.game.combat.Action;
import com.xcity.game.combat.ActionEffect;
import com.xcity.game.combat.Round;
import com.xcity.game.combat.attr.CombatAttributeType;
import com.xcity.game.combat.buff.CombatBuff;
import com.xcity.game.combat.skill.CombatSkill;
import com.xcity.game.combat.unit.CombatUnit;
import com.xcity.game.common.GameStaticConfig;
import com.xcity.game.skill.Skill;

/**
 * 津津乐道<br/>
 * 每回合恢复我方全体{0=10#0}%气势值，持续{1=3#0}回合。
 * @author yang.li
 *
 */
public class COMBAT_SKILL_90089 extends CombatSkill {

	public COMBAT_SKILL_90089(Skill skill) {
		super(skill);
	}

	@Override
	public void calcDamage(Action action) {
		List<CombatUnit> units = action.unit.getTeam().all();
		for (int i = 0; i < units.size(); i++) {
			CombatUnit u = units.get(i);
			if (!u.isDied()) {
//				ActionEffect effect = action.addTarget(u);
//				int val = (int) (u.getMaxHp() * rate); // hp恢复点数
//				effect.effect(CombatAttributeType.HP, val);
				action.addBuff(new BUFF(skill, u));
			}
		}
	}
	
	static class BUFF extends CombatBuff {
		private int hp; // 每回合回血
		public BUFF(Skill skill, CombatUnit owner) {
			super(skill.getTemplate().getCombatBuff(), owner, (int) skill.getParameter(1));
			this.hp = (int) (owner.getMaxHp() * skill.getParameter(0) / GameStaticConfig.percentBase);
		}
		@Override
		public void roundStart(Round round) {
		}
		@Override
		public void preAction(Action action) {
			active = true;
			ActionEffect effect = action.addTarget(owner);
			effect.effect(CombatAttributeType.HP, hp);
		}
	}

}
